package org.game.util;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 国际化工具
 * Created by fxf on 2017/7/25.
 */
public class I18NUtil {
    private I18NUtil() {
    }


    /**
     * 将字符串分解为符合i18n定义的map
     *
     * 语言和语言之前用"#"分隔
     * 语言名称和内容之间用&分隔
     * 语言名称定义在I18NPlugin中
     * 例：zh_CN&中文内容#zh_HK&繁體中文內容#en_US&english content
     */
    public static Map<String, String> spiltByLanguage(String source) {
        if (source == null || "".equals(source)) {
            return null;
        }
        Map<String, String> result = Maps.newHashMap();
        String[] langInfo = source.split("#");

        for (String s : langInfo) {
            String[] subInfo = s.split("&");
            result.put(subInfo[0], subInfo[1]);
        }
        return result;
    }

    public static final String i18n_local_zh_CN = "zh_CN";

    public static final String i18n_local_zh_HK = "zh_HK";

    public static final String i18n_local_zh_TW = "zh_TW";

    public static final String i18n_local_en_US = "en_US";

    public static final String i18n_local_ja = "ja";


}
